SET SERVEROUTPUT ON SIZE 1000000;
SET VERIFY OFF

DECLARE
	l_total_extracted	NUMBER;
	l_total_imported	NUMBER;				
	l_func_id			VARCHAR2(100):='CAPFNDREC_MTL_PARA';

BEGIN
	SELECT COUNT(1)
	INTO l_total_extracted   
	FROM
		MTL_PARAMETERS
	WHERE	Organization_ID	IN	(
				SELECT
					O.Organization_ID
				FROM
					HR_ALL_ORGANIZATION_UNITS	A,
					HR_ALL_ORGANIZATION_UNITS	O
				WHERE	A.Name				=	UPPER('&1')
				AND		O.Business_Group_ID	=	A.Organization_ID
				AND		O.Organization_ID	IN
							(
							SELECT	Organization_ID
							FROM	HR_ORGANIZATION_INFORMATION
							WHERE	Org_Information_Context	IN	('Accounting Information','Operating Unit Information')
							)
								);	
								
	SELECT COUNT(1) 
	INTO l_total_imported
	FROM CRST_FND_MTL_PARA;

	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted: '||TO_CHAR(l_total_extracted)) ;
	dbms_output.put_line('Total Imported:  '||TO_CHAR(l_total_imported));
	IF l_total_extracted <> l_total_imported THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
						
EXCEPTION
	WHEN OTHERS THEN	
		dbms_output.put_line('Function Error: '||l_func_id);			
END;
/
